<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>百度地图标记点</title>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }

        #l-map {
            height: 100%;
            width: 78%;
            float: left;
            border-right: 2px solid #bcbcbc;
        }

        #r-result {
            height: 100%;
            width: 20%;
            float: left;
        }
    </style>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak=kaLBv8Axey6j0ZRMAHaYUhGAKVq4KG9K"></script>
</head>
<body>
<div id="allmap"></div>
</body>
<script>
    // $(document).ready(function () {
    //     $.ajax({
    //         url: 'http://ta.vipgz2.idcfengye.com/EPServer/servlet/web/cargo/findLocation?rid=123456',
    //         type: 'get',
    //         dataType: 'json',
    //         crossDomain: true,
    //         success: function (data) {
    //             var rows = data.rows;
    //             var lon = [];
    //             var lat = [];
    //             for(var i=0;i<rows.length;i++){
    //                 lon[i] = rows[i].longitude;
    //                 lat[i] = rows[i].latitude;
    //             }
    //         }
    //     });
    // });

    //模拟json坐标数据
    var lon = [116.404556,116.316019,116.412605,116.378829,116.445375,116.317744];
    var lat = [39.915378,39.954769,39.854254,39.900102,39.950344,39.889695];

    // 百度地图API功能
    var map = new BMap.Map("allmap");
    //中心点的坐标
    var point = new BMap.Point(116.404556,39.915378);
    map.centerAndZoom(point, 13);
    //允许滚动缩放
    map.enableScrollWheelZoom(true);
    //添加地图控件
    map.addControl(new BMap.NavigationControl());
    map.addControl(new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT}));
    map.addControl(new BMap.OverviewMapControl());
    map.addControl(new BMap.MapTypeControl());

    // 编写自定义函数,创建标注
    function addMarker(point) {
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
    }

    for (var i = 0; i < lon.length; i++) {
        var point = new BMap.Point(lon[i],lat[i]);
        addMarker(point);
    }
</script>
</html>